<?php 

$car =Mage::registry("car_data");
$type = array("1"=>"大","2"=>"中","3"=>"小");

 ?>
<form id="submit_form" method="post" action="<?php echo $this->getUrl('*/*/save'); ?>">
    <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
    <?php if($car && $car->getId()): ?>
          <input name="id" type="hidden" value="<?php echo $car->getId(); ?>" />
    <?php endif; ?>
    <div class="content-header">
        <table cellspacing="0">
            <tbody><tr>
                <td style="width:50%;"><h3 class="icon-head head-products">车载管理</h3></td>
                <td class="a-right">
                        <span id="coupons_generate_button"><button id="id_3cf81872242ced1ce5317b5704e032c7" title="保存" type="button" class="scalable generate" onclick="save()"><span><span><span>保存</span></span></span></button></span>
                </td>
            </tr>
        </tbody></table>
    </div>
    <div class="entry-edit">
        <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend">基本信息</h4>
        <div class="form-buttons"></div>
    </div>
    <div class="fieldset  ignore-validate" id="coupons_information_fieldset">
        <div class="hor-scroll">
        <table cellspacing="0" class="form-list">
            <tbody>
                <?php 
                    $websites = Mage::getModel('core/website')->getCollection()->toOptionHash();
                    $websiteId =Mage::getSingleton('admin/session')->getUser()->getWebsiteId();
                 ?>
                <tr>
                    <td class="label"><label for="status">站点<span class="required">*</span></label></td>
                    <td class="value">
                        <select id="website" name="website_id" class="required-entry select">
                        <?php if($car && $car->getId()): ?>
                        <option value="<?php echo $car->getWebsiteId(); ?>"><?php echo $websites[$car->getWebsiteId()]; ?></option>
                        <?php elseif($websiteId): ?>
                        <option value="<?php echo $websiteId; ?>"><?php echo $websites[$websiteId]; ?></option>  
                        <?php else: ?>
                        <option value="0"></option>
                        <?php foreach ($websites as $key => $website):?>
                        <option value="<?php echo $key ?>"><?php echo $website; ?></option>
                        <?php endforeach; ?>
                        </select>
                        <?php endif; ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><label for="status">类型<span class="required">*</span></label></td>
                    <td class="value">
                        <?php if($car && $car->getId()): ?>
                            <select id="carType" name="car_type" class="required-entry select">
                            <?php foreach($type as $k => $value): ?>
                            <?php if($car->getCarType()==$k): ?>
                                <option value="<?php echo $k; ?>" selected="selected"><?php echo $value; ?></option>
                            <?php else: ?>
                                <option value="<?php echo $k; ?>"><?php echo $value; ?></option>
                            <?php endif;?>
                            <?php endforeach; ?>
                        <?php else: ?>
                            <select id="carType" name="car_type" class="required-entry select">
                            <?php foreach($type as $k => $value): ?>
                                <option value="<?php echo $k; ?>"><?php echo $value; ?></option>
                            <?php endforeach; ?>
                            </select>
                        <?php endif; ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><label for="name">车辆号码<span class="required">*</span></label></td>
                    <?php if($car && $car->getId()): ?>
                        <td class="value">
                             <input id="number" name="number"  title="车辆号码" class="required-entry input-text"  type="text" value="<?php echo $car->getNumber(); ?>">
                        </td>
                    <?php else: ?>
                        <td class="value">
                             <input id="number" name="number"  title="车辆号码" class="required-entry input-text"  type="text">
                        </td>
                    <?php endif; ?>
                </tr>

            </tbody>
        </table>
        </div>
    </div>
</form>

<script type="text/javascript">
    var  $j = jQuery.noConflict();  

    function save(){
        var value = $j(".required-entry");
        var error =new Array();
        value.each(function(index,val){
            if(!$j(val).val()){
                error[index]=index;
            }
        });
        if(error.length){
            layer.alert("带*号都是必填项，请填写");
            return false;
        }
        $j("#submit_form").submit();
    }

</script>